package com.example.tests.lesson2;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;

public class TestHtmlWebsite extends SeleneseTestCase{

	public static void main(String[] args) {
		TestHtmlWebsite testHtml = new TestHtmlWebsite();
		testHtml.startTest();
	}
	
	public void startTest(){
		setUpServer();
		addSelection();
		answerOnNextPrompt();
		assignId();
		captureScreen();
		checkLocator();
	}
	
	public void setUpServer(){
		selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:8080/");
		selenium.start();
		selenium.open("/selenium/index.jsp");
	}
	
	//addSelection
	public void addSelection(){
		selenium.addSelection("id=sel", "Nancy");
		selenium.addSelection("id=sel", "Wang");
	}
	
	public void answerOnNextPrompt(){
		selenium.type("id=prompts", "");
//		selenium.answerOnNextPrompt("Nancy's answer for Prompts!");
	}
	
	public void assignId(){
		selenium.assignId("name=noid", "noidid");
		System.out.println("Value is 1:" + selenium.getValue("id=noidid"));
		System.out.println("Value is 2:" + selenium.getValue("name=noid"));
	}
	
	public void captureScreen(){
		// FIXME
//		selenium.captureEntirePageScreenshot("screenshot.PNG", "");
	}
	
	public void checkLocator(){
		selenium.check("id=boy");
		wt();
		selenium.check("id=girl");
		wt();
		selenium.check("id=hobby");
		selenium.check("id=hobby1");
	}
	
	public void testTry(){
		
	}
	
	public void wt(){
//		try {
////			selenium.wait(2000);
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		}
	}
	

}
